package com.shenmazong.user.controller;

import com.shenmazong.user.pojo.TbAdmin;
import com.shenmazong.user.service.TbAdminService;
import com.shenmazong.utils.ResultResponse;
import com.shenmazong.vo.ChangePasswordVo;
import com.shenmazong.vo.IdVo;
import com.shenmazong.vo.LoginVo;
import com.shenmazong.vo.PageVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 军哥
 * @version 1.0
 * @description: TbAdminController
 * @date 2022/8/2 15:37
 */

@RestController
@Slf4j
@RequestMapping(value = "/admin")
public class TbAdminController {

    @Autowired
    TbAdminService tbAdminService;

    @PostMapping(value = "/add")
    public ResultResponse add(@RequestBody TbAdmin tbAdmin) {
        return tbAdminService.add(tbAdmin);
    }

    @PostMapping(value = "/del")
    public ResultResponse del(@RequestBody IdVo idVo) {
        return tbAdminService.del(idVo);
    }

    @PostMapping(value = "/set")
    public ResultResponse set(@RequestBody TbAdmin tbAdmin) {
        return tbAdminService.set(tbAdmin);
    }

    @PostMapping(value = "/get")
    public ResultResponse get(@RequestBody IdVo idVo) {
        return tbAdminService.get(idVo);
    }

    @PostMapping(value = "/list")
    public ResultResponse list(@RequestBody PageVo pageVo) {
        return tbAdminService.ListByPage(pageVo);
    }

    @PostMapping(value = "/changePassword")
    public ResultResponse changePassword(@RequestBody ChangePasswordVo changePasswordVo) {
        return tbAdminService.changePassword(changePasswordVo);
    }

    @PostMapping(value = "/login")
    public ResultResponse login(@RequestBody LoginVo loginVo) {
        return tbAdminService.login(loginVo);
    }

}
